package com.example.demo.Vo;

import com.example.demo.Entity.ShopUser;
import lombok.Data;
import net.minidev.json.annotate.JsonIgnore;

@Data
public class UserVo {
    private String uid;
    private String name;
    private String password;
    private String email;
    private boolean isAdmin;
    private boolean available;
    private boolean isVIP;


    @JsonIgnore
    private String verificationCode = null;
    @JsonIgnore
    private static int totUserNum = 0;

    @JsonIgnore
    public UserVo(String uid, String password, String email, String verificationCode) {
        this.uid = uid;
        this.password = password;
        this.email = email;
        this.verificationCode = verificationCode;
    }

    @JsonIgnore
    public static ShopUser ToUser(UserVo userVo) {
        ShopUser user = new ShopUser();
        user.setUserID(userVo.uid);
        user.setEmail(userVo.email);
        user.setUserPassword(userVo.password);
        user.setUsername("用户" + String.format("%09d", (int) (Math.random() * 100000000)));
        user.setUserSignature("这个人很懒，什么都没有写");
        user.setAddress("");
        return user;
    }

}